class Stack():
    class Node():
        def __init__(self, value=0, next=None):
            self.value = value
            self.next = next#栈内的前一个，上一个栈元素指针

    def __init__(self):
        self.head = self.Node()#哨兵节点
        self.size = 0

    def is_empty(self):
        return self.size == 0
    
    def length(self):
        return self.size
    
    def push(self, value):
        new_node = self.Node(value)
        new_node.next = self.head
        self.head = new_node
        self.size += 1
        pass

    def pop(self):
        self.size -= 1
        old_head = self.head
        self.head = self.head.next
        return old_head.value
    
    def peek(self):
        return self.head.value
    

st = Stack()
list = ["a","b","c","d"]
for i in list:
    st.push(i)

print(st.length())

for i in range(st.length()):
    val = st.pop()
    print(val)